Telegram Group & Telegram Channel
Forwarded from Python/ django
🐍 Π—Π°Π΄Π°Ρ‡Π° ΠΏΠΎ Python: Замыкания ΠΈ области видимости

Π§Ρ‚ΠΎ Π²Ρ‹Π²Π΅Π΄Π΅Ρ‚ ΡΠ»Π΅Π΄ΡƒΡŽΡ‰ΠΈΠΉ ΠΊΠΎΠ΄?


def outer():
x = 5
def inner():
nonlocal x
x += 1
return x
return inner

f = outer()
print(f())
print(f())
print(f())


Π’Π°Ρ€ΠΈΠ°Π½Ρ‚Ρ‹ ΠΎΡ‚Π²Π΅Ρ‚Π°:
A)

7
8


B)

5
5


C)

6
6


D) Ошибка выполнСния

---

βœ… ΠŸΡ€Π°Π²ΠΈΠ»ΡŒΠ½Ρ‹ΠΉ ΠΎΡ‚Π²Π΅Ρ‚: A

ΠŸΠΎΡ‡Π΅ΠΌΡƒ:
Ѐункция
outer создаёт Π·Π°ΠΌΡ‹ΠΊΠ°Π½ΠΈΠ΅. ΠŸΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Π°Ρ x сохраняСтся ΠΌΠ΅ΠΆΠ΄Ρƒ Π²Ρ‹Π·ΠΎΠ²Π°ΠΌΠΈ f, ΠΏΠΎΡ‚ΠΎΠΌΡƒ Ρ‡Ρ‚ΠΎ inner β€” Π·Π°ΠΌΡ‹ΠΊΠ°Π΅Ρ‚ x ΠΈ измСняСт Π΅Ρ‘ с ΠΏΠΎΠΌΠΎΡ‰ΡŒΡŽ nonlocal. Π­Ρ‚ΠΎ классичСский ΠΏΡ€ΠΈΠΌΠ΅Ρ€ использования Π·Π°ΠΌΡ‹ΠΊΠ°Π½ΠΈΠΉ Π² Python.

@pythonl



tg-me.com/python_testit/1160
Create:
Last Update:

🐍 Π—Π°Π΄Π°Ρ‡Π° ΠΏΠΎ Python: Замыкания ΠΈ области видимости

Π§Ρ‚ΠΎ Π²Ρ‹Π²Π΅Π΄Π΅Ρ‚ ΡΠ»Π΅Π΄ΡƒΡŽΡ‰ΠΈΠΉ ΠΊΠΎΠ΄?


def outer():
x = 5
def inner():
nonlocal x
x += 1
return x
return inner

f = outer()
print(f())
print(f())
print(f())


Π’Π°Ρ€ΠΈΠ°Π½Ρ‚Ρ‹ ΠΎΡ‚Π²Π΅Ρ‚Π°:
A)

7
8


B)

5
5


C)

6
6


D) Ошибка выполнСния

---

βœ… ΠŸΡ€Π°Π²ΠΈΠ»ΡŒΠ½Ρ‹ΠΉ ΠΎΡ‚Π²Π΅Ρ‚: A

ΠŸΠΎΡ‡Π΅ΠΌΡƒ:
Ѐункция
outer создаёт Π·Π°ΠΌΡ‹ΠΊΠ°Π½ΠΈΠ΅. ΠŸΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Π°Ρ x сохраняСтся ΠΌΠ΅ΠΆΠ΄Ρƒ Π²Ρ‹Π·ΠΎΠ²Π°ΠΌΠΈ f, ΠΏΠΎΡ‚ΠΎΠΌΡƒ Ρ‡Ρ‚ΠΎ inner β€” Π·Π°ΠΌΡ‹ΠΊΠ°Π΅Ρ‚ x ΠΈ измСняСт Π΅Ρ‘ с ΠΏΠΎΠΌΠΎΡ‰ΡŒΡŽ nonlocal. Π­Ρ‚ΠΎ классичСский ΠΏΡ€ΠΈΠΌΠ΅Ρ€ использования Π·Π°ΠΌΡ‹ΠΊΠ°Π½ΠΈΠΉ Π² Python.

@pythonl

BY Python tests


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/python_testit/1160

View MORE
Open in Telegram


Python tests Telegram | DID YOU KNOW?

Date: |

Telegram has exploded as a hub for cybercriminals looking to buy, sell and share stolen data and hacking tools, new research shows, as the messaging app emerges as an alternative to the dark web.An investigation by cyber intelligence group Cyberint, together with the Financial Times, found a ballooning network of hackers sharing data leaks on the popular messaging platform, sometimes in channels with tens of thousands of subscribers, lured by its ease of use and light-touch moderation.

The messaging service and social-media platform owes creditors roughly $700 million by the end of April, according to people briefed on the company’s plans and loan documents viewed by The Wall Street Journal. At the same time, Telegram Group Inc. must cover rising equipment and bandwidth expenses because of its rapid growth, despite going years without attempting to generate revenue.

Python tests from pl


Telegram Python tests
FROM USA